package com.ftg.product.exam.service.impl;

import com.diboot.core.util.BeanUtils;
import com.ftg.product.exam.entity.SysOrganizations;
import com.ftg.product.exam.mapper.SysOrganizationsMapper;
import com.ftg.product.exam.service.SysOrganizationsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
* 组织机构表,
1.1 组织机构信息（学院名称、学院地址、学院说明、）
1.2 部门信息(名称、说明、地址)相关Service实现
* @author kangjx
* @version 1.0
* @date 2021-01-14
 * Copyright © ftg
*/
@Service
@Slf4j
public class SysOrganizationsServiceImpl extends BaseCustomServiceImpl<SysOrganizationsMapper, SysOrganizations> implements SysOrganizationsService {

    @Autowired
    SysOrganizationsMapper sysOrganizationsMapper;

    @Override
    public int delete(Long id) {
        List<Map<String,Object>> list = selectemp(id);
        if (list == null | list.equals("")){
            return sysOrganizationsMapper.deleteById(id);
        }else {
        deletebyemporgcode(id);
        return sysOrganizationsMapper.deleteById(id);
        }
    }

    @Override
    public List<Map<String, Object>> selectemp(Long emporgcode) {
        return sysOrganizationsMapper.selectemp(emporgcode);
    }

    @Override
    public int deletes(List<Long> ids) {
        if (ids == null | ids.size() == 0){
            return 0;
        }
        sysOrganizationsMapper.deletes(ids);
        return sysOrganizationsMapper.deleteBatchIds(ids);
    }

    public int deletebyemporgcode(Long id){
        return sysOrganizationsMapper.deletebyemporgcode(id);
    }
}
